package com.yunxitest.yunxitest.item.light;

import java.io.FileOutputStream;

public class LedUtil {
    private static final String TAG = "LED";
    int mLedStatus = 0;
    private final int mLedColorRed = 0xFFFF0000;
    private final int mLedColorGreen = 0xFF00FF00;
    static final byte[] LIGHT_ON = {'2', '5', '5'};
    static final byte[] LIGHT_OFF = {'0'};
    public static final int RED = 0;
    public static final int GREEN = 1;
    public static final int OFF = 2;
    static String RED_LED_DEV = "/sys/class/leds/red/brightness";
    static String GREEN_LED_DEV = "/sys/class/leds/green/brightness";


    public static void setledlightcolor(int color) {
        boolean red = false, green = false, off = false;
        switch (color) {
            case RED:
                red = true;
                break;

            case GREEN:
                green = true;
                break;

            case OFF:
                off = true;
                break;
            default:
                break;
        }
        try {
            FileOutputStream fRed = new FileOutputStream(RED_LED_DEV);
            fRed.write(red ? LIGHT_ON : LIGHT_OFF);
            fRed.close();

            FileOutputStream fGreen = new FileOutputStream(GREEN_LED_DEV);
            fGreen.write(green ? LIGHT_ON : LIGHT_OFF);
            fGreen.close();

        } catch (Exception e) {
        }
    }


}
